/**
 * 
 */
package com.yst.metho.web.application.team;

import java.util.Collection;

import nextapp.echo2.app.Column;
import nextapp.echo2.app.Extent;
import nextapp.echo2.app.Insets;
import nextapp.echo2.app.Label;
import nextapp.echo2.app.Row;
import nextapp.echo2.app.SelectField;
import nextapp.echo2.app.TextField;

import com.yst.metho.web.application.rights.ProfilListCellRenderer;
import com.yst.metho.web.application.rights.ProfilListModel;
import com.yst.suivi.data.rights.Profil;

/**
 * @author yannick
 * 
 */
public class TeamRolePane extends Column
{
	private TextField mNom;

	private SelectField mSelectField;

	public TeamRolePane(Collection profils)
	{
		super();
		setCellSpacing(new Extent(10));
		setInsets(new Insets(10));

		Row row = new Row();
		Label lbl = new Label("Role");
		row.add(lbl);

		mNom = new TextField();
		row.add(mNom);
		add(row);

		row = new Row();
		lbl = new Label("Profil");
		row.add(lbl);

		mSelectField = new SelectField();
		mSelectField.setModel(new ProfilListModel(profils));
		mSelectField.setCellRenderer(new ProfilListCellRenderer());
		mSelectField.setSelectedIndex(0);
		row.add(mSelectField);
		add(row);
	}

	public String getNom()
	{
		return mNom.getText();
	}

	public String getProfil()
	{
		return ((Profil) mSelectField.getSelectedItem()).getNom();
	}

	public String getProfilId()
	{
		return ((Profil) mSelectField.getSelectedItem()).getId();
	}
}
